package com.logic.modular.game.battle.panel.skillEffect;

import java.io.Serializable;
import java.util.*;

import com.logic.comment.exection.PlannerException;
import com.logic.modular.game.battle.process.domain.EffectTriggerInfo;
import com.logic.modular.game.battle.panel.skillEffect.domain.BaseEffectValueInfo;
import com.logic.modular.game.battle.panel.skillEffect.domain.BaseTrigger;
import com.logic.modular.game.battle.panel.skillEffect.domain.SkillEffectLayer;
import com.logic.modular.game.battle.panel.skillEffect.domain.SkillEffectStatus;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.extern.slf4j.Slf4j;

/**
 * 技能效果
 *
 * @author cxy
 * @since 2024-08-22 11:35:33
 */
@ApiModel("技能效果")
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Slf4j
public class PvpSkillEffect implements Serializable {// swagger2,mybatis-plus
    @ApiModelProperty("技能效果id")
    private Long coreSkillEffectId;
    //////////////////////////////////////////////////////////////////////////////////////////////////////////  基础部分
    @ApiModelProperty("战斗编号")
    private String battleUUID;
    @ApiModelProperty("战斗id")
    private Long battleId;
    @ApiModelProperty("释放回合数")
    private Integer round;
    @ApiModelProperty("来源武将id")
    private Long sourcePlayerHeroId;
    @ApiModelProperty("来源的武将名字")
    private String sourcePlayerHeroName;
    @ApiModelProperty("被施加效果的武将id")
    private Long targetPlayerHeroId;
    @ApiModelProperty("被施加效果的武将名字")
    private String targetPlayerHeroName;
    //////////////////////////////////////////////////////////////////////////////////////////////////////////   技能信息
    @ApiModelProperty("来源技能id")
    private Long sourceCoreSkillId;
    @ApiModelProperty("技能名字")
    private String coreSkillName;
    @ApiModelProperty("技能描述")
    private String coreSkillInfo;
    @ApiModelProperty("技能来源类型 指挥,被动,主动,追击")
    private Integer coreSkillTyp;
    @ApiModelProperty("星阶id")
    private Long sourceCoreSkillStarId;
    @ApiModelProperty("是否受策略影响")
    private Integer isMagic;
    @ApiModelProperty("受策略影响系数 可能是战法指定的伤害率")
    private Integer magicInfluence;
    ///////////////////////////////////////////////////////////////////////////////////////////////////////// 技能效果数值
    @ApiModelProperty("基础触发信息")
    private BaseTrigger baseTrigger;
    @ApiModelProperty("基础技能效果数值信息")
    private BaseEffectValueInfo baseEffectValueInfo;
    @ApiModelProperty("叠加信息")
    private SkillEffectLayer skillEffectLayer;
    ///////////////////////////////////////////////////////////////////////////////////////////////////////// 技能效果类型
    @ApiModelProperty("技能效果信息类型id")
    private Long coreSkillEffectTypeId;
    @ApiModelProperty("技能效果名称")
    private String coreSkillEffectTypeName;
    @ApiModelProperty("技能效果类型  0:血量类 1:属性类 11:状态类 20:dot类 21:控制类")
    private Integer coreSkillEffectTypeType;
    @ApiModelProperty("免疫部分")
    private Set<Long> immunityList;
    @ApiModelProperty("移除部分")
    private Set<Long> removeList;
    /////////////////////////////////////////////////////////////////////////////////////////////////////    技能效果结果
    @ApiModelProperty("技能效果状态")
    public SkillEffectStatus status;

    // 返回信息
    public EffectTriggerInfo skillEffectTriggerInfo;


    /**
     * 获取有效回合
     * @return 有效回合
     */
    public List<Integer> obtainNumberOfEffectiveRounds() {
        Integer appoint = baseTrigger.getAppoint();
        Integer keep = baseTrigger.getKeep();
        Integer prepare = baseTrigger.getPrepare();
        List<Integer> list = new ArrayList<>();
        if (appoint < 1) {
            for (Integer i = 0; i < keep; i++) {
                list.add(round + prepare + i);// 释放+准备+第i保存回合
            }
        }
        if (appoint >= 1) {
            for (Integer i = 0; i < keep; i++) {
                list.add(appoint + prepare + i);// 指定+准备+第i保存回合
            }
        }
        if (keep < 0){
            throw new PlannerException("keep不能小于0");
        }
        return list;
    }

    public boolean pdTrigger5(Map<Long, Object> behaviorMap){
        List<Long> trigger5 = baseTrigger.getTrigger5();
        for (Long l : trigger5) {
            if (behaviorMap.containsKey(l)) {
                return true;
            }
        }
        return false;
    }


    public String obtainSkillInfo() {
        return "目标武将:" + targetPlayerHeroId + "-"
                + "技能id:" + sourceCoreSkillId + "-"
                + "技能星阶id:" + sourceCoreSkillStarId + "-"
                + "技能名称:" + coreSkillName + "-"
                + "[技能描述:" + coreSkillInfo + "]";
    }




}

